import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:number_spark_flutter/style/ns_style.dart';
import 'package:number_spark_flutter/utils/ns_user_utils.dart';
import 'package:number_spark_flutter/widgets/brick/ns_brick.dart';
import 'package:number_spark_flutter/widgets/ns_white_app_bar.dart';

import 'ns_setting_logic.dart';

class NSSettingPage extends StatelessWidget {
  NSSettingPage({Key? key}) : super(key: key);

  final logic = Get.put(NSSettingLogic());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: kAppColor('#F6F6F6'),
      body: Stack(
        children: [
          const NSImage(
            assetImage: 'img_bg_main.png',
            width: double.infinity,
            height: double.infinity,
            fit: BoxFit.fill,
          ),
          Column(
            children: [
              const NSWhiteAppBar(
                'Setting',
              ),
              SizedBox(height: 50.h),
              buildSettingItem(title: 'id: ${NSUserUtils.getId()}', onTap: () {}),
              buildSettingItem(title: 'Logout', onTap: logic.onLogout),
              buildSettingItem(title: 'Delete Account', onTap: logic.onDeleteAccount),
            ],
          )
        ],
      ),
    );
  }

  buildSettingItem({required String title, required onTap}) {
    return NSStack(
      margin: EdgeInsets.only(bottom: 23.h, left: 30.w, right: 30.w),
      alignment: Alignment.centerLeft,
      onTap: onTap,
      children: [
        Center(
          child: NSImage(
            assetImage: 'img_bg_mine_btn.png',
            width: 316.w,
          ),
        ),
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Stack(
              children: [
                NSText(
                  margin: EdgeInsets.only(left: 20.w),
                  text: title,
                  fontSize: 24.sp,
                  fontFamily: 'Modak-Regular',
                  foreground: Paint()
                    ..style = PaintingStyle.stroke
                    ..strokeWidth = 1.5
                    ..color = kAppColor('#FF4BA611'),
                ),
                NSText(
                  margin: EdgeInsets.only(left: 20.w),
                  text: title,
                  textColor: Colors.white,
                  fontSize: 24.sp,
                  fontFamily: 'Modak-Regular',
                ),
              ],
            ),
          ],
        )
      ],
    );
  }
}
